package com.zhentao.service.impl;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhentao.mapper.AdminMenuMapper;
import com.zhentao.model.common.admin.pojo.AdminMenu;
import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.service.AdminMenuService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author liu
* @description 针对表【admin_menu】的数据库操作Service实现
* @createDate 2024-09-14 18:34:09
*/
@Service
public class AdminMenuServiceImpl extends ServiceImpl<AdminMenuMapper, AdminMenu>
        implements AdminMenuService {
    @Resource
    private AdminMenuMapper adminMenuMapper;

    @Override
    public ResponseResult listAll() {
        //查询父级菜单
        List<AdminMenu> adminParentMenus = adminMenuMapper.selectList(Wrappers.<AdminMenu>lambdaQuery().eq(AdminMenu::getParentId, 0));

        for (AdminMenu adminParentMenu : adminParentMenus) {
            List<AdminMenu> adminMenus = adminMenuMapper.selectList(Wrappers.<AdminMenu>lambdaQuery().eq(AdminMenu::getParentId, adminParentMenu.getId()));

            adminParentMenu.setMenus(adminMenus);
        }

        return ResponseResult.okResult(adminParentMenus);
    }
}




